package org.jeecg.modules.hc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum HcDeliveryStatusEnum {
    NO("no", "未取餐"),
    YES("yes", "已取餐"),
    ;

    @EnumValue
    private final String value;
    @JsonValue
    private final String name;

    HcDeliveryStatusEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HcDeliveryStatusEnum get(String val) {
        Optional<HcDeliveryStatusEnum> first = Arrays.stream(HcDeliveryStatusEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    public static HcDeliveryStatusEnum getByName(String name) {
        Optional<HcDeliveryStatusEnum> first = Arrays.stream(HcDeliveryStatusEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return first.orElse(null);
    }
}
